﻿using Pay.DTO;
using Pay.Tool;

namespace Pay.Core
{
	/// <summary>
	/// MyHostedService
	/// </summary>
	public class MyHostedService : BackgroundService
	{
		/// <summary>
		/// ExecuteAsync
		/// </summary>
		protected override Task ExecuteAsync(CancellationToken stoppingToken)
		{
			InitPayConfig();
			return Task.CompletedTask;
		}

		#region private methods
		/// <summary>
		/// 初始化支付配置
		/// </summary>
		private void InitPayConfig()
		{
			var path = ToolHelper.PayConfigPath;
			if (File.Exists(path))
			{
				var dic = ToolHelper.JsonToObj<Dictionary<PayCategoryEnum, PayConfigDto>>(path);
				if (dic != null)
					Data.PayConfigDic = dic;
			}
		}
		#endregion
	}
}
